package com.jy.wms.controller;

import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
import org.jeecgframework.poi.excel.export.styler.AbstractExcelExportStyler;
import org.jeecgframework.poi.excel.export.styler.IExcelExportStyler;

/**
 * @ClassName: ExcelExportStylerBorderImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @Author zzp
 * @Date 2017/10/12 11:01
 */
public class ExcelExportStylerBorderImpl extends AbstractExcelExportStyler implements IExcelExportStyler {
    public ExcelExportStylerBorderImpl(Workbook workbook) {
        super.createStyles(workbook);
    }
    @Override
    public CellStyle getHeaderStyle(short headerColor) {
        CellStyle titleStyle = this.workbook.createCellStyle();
        Font font = this.workbook.createFont();
        font.setFontHeightInPoints((short) 24);
        titleStyle.setFont(font);
        titleStyle.setFillForegroundColor(headerColor);
        titleStyle.setAlignment((short) 2);
        titleStyle.setVerticalAlignment((short) 1);
        return titleStyle;
    }

    @Override
    public CellStyle getTitleStyle(short color) {
        CellStyle titleStyle = this.workbook.createCellStyle();
        titleStyle.setFillForegroundColor(color);
        titleStyle.setBorderLeft((short) 1);
        titleStyle.setBorderRight((short) 1);
        titleStyle.setBorderBottom((short) 1);
        titleStyle.setBorderTop((short) 1);
        titleStyle.setAlignment((short) 2);
        titleStyle.setAlignment((short) 2);
        titleStyle.setVerticalAlignment((short) 1);
        titleStyle.setFillPattern((short) 1);
        titleStyle.setWrapText(true);
        return titleStyle;
    }

    @Override
    public CellStyle getStyles(boolean b, ExcelExportEntity excelExportEntity) {
        return null;
    }
    public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) {
        CellStyle style = workbook.createCellStyle();
        style.setBorderLeft((short) 1);
        style.setBorderRight((short) 1);
        style.setBorderBottom((short) 1);
        style.setBorderTop((short) 1);
        style.setAlignment((short) 2);
        style.setVerticalAlignment((short) 1);
        style.setDataFormat(STRING_FORMAT);
        if(isWarp) {
            style.setWrapText(true);
        }

        return style;
    }



    public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) {
        CellStyle style = workbook.createCellStyle();
        style.setBorderLeft((short) 1);
        style.setBorderRight((short) 1);
        style.setBorderBottom((short) 1);
        style.setBorderTop((short) 1);
        style.setFillForegroundColor((short) 41);
        style.setFillPattern((short) 1);
        style.setAlignment((short) 2);
        style.setVerticalAlignment((short) 1);
        style.setDataFormat(STRING_FORMAT);
        if(isWarp) {
            style.setWrapText(true);
        }

        return style;
    }
}
